import req from '@/http/http'
import config from '@/config/index'
const ZHPQ_SERVER = config.serverUrl()

// 单位
// 新增单位
export const createUnit = data => {
  let path = ZHPQ_SERVER + '/unit/'
  return req.post(path, data)
}
// 查询列表
export const findUnit = data => {
  let path = ZHPQ_SERVER + '/unit'
  return req.get(path, data)
}
// 修改单位
export const updateUnit = data => {
  let path = ZHPQ_SERVER + '/unit/' + data.id
  return req.put(path, data)
}
// 删除单位
export const deleteUnit = data => {
  let path = ZHPQ_SERVER + '/unit/' + data.id
  return req.delete(path)
}
// 获取当条详细信息
export const getUnit = id => {
  let path = ZHPQ_SERVER + '/unit/' + id
  return req.get(path)
}

// 部门
// 新增部门
export const createDept = data => {
  let path = ZHPQ_SERVER + '/dept/'
  return req.post(path, data)
}
// 查询列表
export const findDept = data => {
  let path = ZHPQ_SERVER + '/dept'
  return req.get(path, data)
}
// 修改部门
export const updateDept = data => {
  let path = ZHPQ_SERVER + '/dept/' + data.id
  return req.put(path, data)
}
// 删除部门
export const deleteDept = data => {
  let path = ZHPQ_SERVER + '/dept/' + data.id
  return req.delete(path)
}
// 获取当条详细信息
export const getDept = id => {
  let path = ZHPQ_SERVER + '/dept/' + id
  return req.get(path)
}

// 用户
// 新增用户
export const createUser = data => {
  let path = ZHPQ_SERVER + '/user/'
  return req.post(path, data)
}
// 查询列表
export const findUser = data => {
  let path = ZHPQ_SERVER + '/user'
  return req.get(path, data)
}
// 修改用户
export const updateUser = data => {
  let path = ZHPQ_SERVER + '/user/' + data.id
  return req.put(path, data)
}
// 删除用户
export const deleteUser = data => {
  let path = ZHPQ_SERVER + '/user/' + data.id
  return req.delete(path)
}
// 获取当条详细信息
export const getUser = id => {
  let path = ZHPQ_SERVER + '/user/' + id
  return req.get(path)
}

// 字典类型
// 新增字典类型
export const createDictionType = data => {
  let path = ZHPQ_SERVER + '/dictionaryType/'
  return req.post(path, data)
}
// 查询列表
export const findDictionType = data => {
  let path = ZHPQ_SERVER + '/dictionaryType'
  return req.get(path, data)
}
// 修改字典类型
export const updateDictionType = data => {
  let path = ZHPQ_SERVER + '/dictionaryType/' + data.id
  return req.put(path, data)
}
// 删除字典类型
export const deleteDictionType = data => {
  let path = ZHPQ_SERVER + '/dictionaryType/' + data.id
  return req.delete(path)
}
// 获取当条详细信息
export const getDictionType = id => {
  let path = ZHPQ_SERVER + '/dictionaryType/' + id
  return req.get(path)
}

// 字典值方法
// 新增字典
export const createDictionItem = data => {
  let path = ZHPQ_SERVER + '/dictionaryItem/'
  return req.post(path, data)
}
// 查询列表
export const findDictionItem = data => {
  let path = ZHPQ_SERVER + '/dictionaryItem'
  return req.get(path, data)
}
// 修改字典
export const updateDictionItem = data => {
  let path = ZHPQ_SERVER + '/dictionaryItem/' + data.id
  return req.put(path, data)
}
// 删除字典
export const deleteDictionItem = data => {
  let path = ZHPQ_SERVER + '/dictionaryItem/' + data.id
  return req.delete(path)
}
// 获取当条详细信息
export const getDictionItem = id => {
  let path = ZHPQ_SERVER + '/dictionaryItem/' + id
  return req.get(path)
}

// 角色增加
// 新增角色
export const createRole = data => {
  let path = ZHPQ_SERVER + '/role/'
  return req.post(path, data)
}
// 查询列表
export const findRole = data => {
  let path = ZHPQ_SERVER + '/role'
  return req.get(path, data)
}
// 修改角色
export const updateRole = data => {
  let path = ZHPQ_SERVER + '/role/' + data.id
  return req.put(path, data)
}
// 删除角色
export const deleteRole = data => {
  let path = ZHPQ_SERVER + '/role/' + data.id
  return req.delete(path)
}
// 获取当条详细信息
export const getRole = id => {
  let path = ZHPQ_SERVER + '/role/' + id
  return req.get(path)
}

// 角色权限
export const createRolePermission = data => {
  return req.post('/rolePermission/', data)
}
export const getAllRole = data => {
  let path = ZHPQ_SERVER + '/role/list'
  return req.get(path, data)
}
export const findPermissionIdsByRoleId = data => {
  let path = ZHPQ_SERVER + '/rolePermission/' + data.id + '/p/ids'
  return req.get(path)
}

// 权限增加
// 新增权限
export const createPermission = data => {
  let path = ZHPQ_SERVER + '/permission/'
  return req.post(path, data)
}
// 查询列表
export const findPermission = data => {
  let path = ZHPQ_SERVER + '/permission'
  return req.get(path, data)
}
// 修改权限
export const updatePermission = data => {
  let path = ZHPQ_SERVER + '/permission/' + data.id
  return req.put(path, data)
}
// 删除权限
export const deletePermission = data => {
  let path = ZHPQ_SERVER + '/permission/' + data.id
  return req.delete(path)
}
// 获取当条详细信息
export const getPermission = id => {
  let path = ZHPQ_SERVER + '/permission/' + id
  return req.get(path)
}
export const getPermissionAllTree = data => {
  let path = ZHPQ_SERVER + '/permission/all/tree'
  return req.get(path, data)
}
